<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='lb' /></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">

            <div class="layui-form-item">
                <form name="totalForm" id="totalForm" action="${web_domain}/merchant/billLading/list" method="get">

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='ddbh' /></label>
                        <div class="layui-input-inline">
                            <input type="text" name="orderNo" placeholder="<fmt:message key='srddbh' />" value="<c:if test='${params.orderNo !=null}'>${params.orderNo}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='shr' /></label>
                        <div class="layui-input-inline">
                            <input type="text" name="deliveryName" placeholder="<fmt:message key='ssshrxm' />" value="<c:if test='${params.deliveryName !=null}'>${params.deliveryName}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label"><fmt:message key='sjh' /></label>
                        <div class="layui-input-inline">
                            <input type="text" name="deliveryMobile" placeholder="<fmt:message key='ssshrsjh' />" value="<c:if test='${params.deliveryMobile !=null}'>${params.deliveryMobile}</c:if>" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" id="search"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i> 搜索</button>
                    </div>
                </form>
            </div>
        </div>

    </div>

    <div class="layui-card">
        <div class="layui-field-box layui-form">

            <table class="layui-table" lay-size="sm">
                <thead>
                <th><fmt:message key='xh' /></th>
                <th><fmt:message key='ddbh' /></th>
                <th><fmt:message key='shr' /></th>
                <th><fmt:message key='dh' /></th>
                <th><fmt:message key='shdz' /></th>
                <th>
                    <fmt:message key='ddzj' />
                </th>
                <th><fmt:message key='ddzt' /></th>
                <th><fmt:message key='thsj' /></th>
                <th><fmt:message key='cz' /></th>
                </thead>
                <c:forEach items="${page.result}" var="item" varStatus="status">
                    <tr>
                        <td>${status.index + 1 }</td>
                        <td>${item.orderNo }</td>
                        <td>${item.deliveryName}</td>
                        <td>${item.deliveryMobile}</td>
                        <td>${item.deliveryProvince}${item.deliveryCity}${item.deliveryArea}${item.deliveryAddress}</td>
                        <td><fmt:formatNumber value="${item.price}" type="CURRENCY"/></td>
                        <td>
                            <c:choose>
                                <c:when test="${item.status eq 1}"><fmt:message key='dfk' /></c:when>
                                <c:when test="${item.status eq 2}"><fmt:message key='dfh' /></c:when>
                                <c:when test="${item.status eq 3}"><fmt:message key='dsh' /></c:when>
                                <c:when test="${item.status eq 4}"><fmt:message key='ddqs' /></c:when>
                            </c:choose>
                        </td>
                        <td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        <td>
                            <div class="layui-btn-container">
                                <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-detail"><fmt:message key='ck' /></a>

                                <c:choose>
                                    <c:when test="${item.status eq 1}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-danger layui-btn-xs feijin-pay"><fmt:message key='zf' /></a>
                                    </c:when>
                                    <c:when test="${item.status eq 3 && item.order == null}">
                                        <a href="javascript:void(0);" data-id="${item.id}" class="layui-btn layui-btn-xs feijin-finish"><fmt:message key='qs' /></a>
                                    </c:when>
                                </c:choose>
                            </div>
                        </td>
                    </tr>
                </c:forEach>
            </table>
            <jsp:include page="/commons/page.jsp" flush="true"/>
        </div>
    </div>

</div>

<script>


    layui.use(['form', 'laydate'], function () {

        var form = layui.form;
        var laydate = layui.laydate;

    });

    $(function () {

        //查看详情
        $(".feijin-detail").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='ckxq' />'
                , content: '${web_domain}/merchant/billLading/details?id=' + id
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh' />']
            });
        });


        //支付
        $(".feijin-pay").click(function () {

            var id = $(this).attr("data-id");

            layer.open({
                type: 2
                , title: '<fmt:message key='zfyf' />'
                , content: '${web_domain}/merchant/billLading/' + id + '/pay'
                , maxmin: true
                , area: ['97%', '97%']
                , btn: ['<fmt:message key='fh' />']
            });
        });

        //签收
        $(".feijin-finish").click(function () {
            var id = $(this).attr("data-id");
            layer.confirm("<fmt:message key='qrshm' />？", function () {
                feijin.put({
                    url: "${web_domain}/merchant/billLading/finish",
                    data: {
                        id: id
                    }
                })

            });
        });

    });
</script>
</body>
</fmt:bundle>
</html>
